package com.onpositive.storage.managers;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class AccountManager {
	private static UserService service = UserServiceFactory.getUserService();
	
	private static AccountManager manager = null;
	
	public static AccountManager getAccountManager(){
		if(manager != null){
			return manager;			
		}else{
			manager = new AccountManager();
			return manager;
		}
	}
	
	public static UserService getService() {
		return service;
	}

	private AccountManager(){
	 
	}
	
	public static boolean isUserLoginned(){
		User currentUser = service.getCurrentUser();
		boolean flg = currentUser != null && service.isUserLoggedIn() && service.isUserAdmin();
		return flg;
	}
	
	public static String getCurrentUserNickName(){
		User user = service.getCurrentUser();
		if( user != null){
			return user.getNickname();
		}
		
		return "";
	}
}
